package com.ljkj.blockpay.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.ValueCallback;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.ljkj.blockpay.R;
import com.ljkj.blockpay.basedata.BaseActivity;
import com.ljkj.blockpay.databinding.ActivityWebviewBinding;
import com.ljkj.blockpay.presenter.AdvancedPresenter;
import com.ljkj.blockpay.widget.ClickListener;
import com.ljkj.blockpay.widget.JsBridge;

public class WebViewActivity extends BaseActivity<ActivityWebviewBinding, AdvancedPresenter> implements ClickListener {

    @Override
    public int initContentView() {
        return R.layout.activity_webview;
    }

    @Override
    protected AdvancedPresenter createPresenter() {
        return null;
    }

    @Override
    protected void init(Bundle savedInstanceState) {

    }

    @Override
    protected void initData() {
        super.initData();
        WebView mWeb = findViewById(R.id.mweb);

        mWeb.getSettings().setUseWideViewPort(true);
        mWeb.getSettings().setLoadWithOverviewMode(true);
        mWeb.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        mWeb.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                mWeb.loadUrl("file:///android_asset/new_file.html");
                return true;
            }
        });

        mWeb.getSettings().setJavaScriptEnabled(true);
        mWeb.addJavascriptInterface(new JsBridge(),"jsBridge");
        mWeb.loadUrl("file:///android_asset/new_file.html");
//        mWeb.evaluateJavascript("javascript:window.callbckName", new ValueCallback<String>() {
//            @Override
//            public void onReceiveValue(String s) {
//
//            }
//        });

    }

    @Override
    public void onClick(View view) {

    }
}